package A_c3p0;

import b_utils.JDBCUtils;
import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo3 {
    public static void main(String[] args) throws SQLException {
        Connection conn1 = JDBCUtils.getConnection();
        System.out.println(conn1);
        ComboPooledDataSource ds = new ComboPooledDataSource();
        Connection conn2 = ds.getConnection();
        System.out.println(conn2);
        Statement sta1 = conn1.createStatement();
        Statement sta2 = conn2.createStatement();
        System.out.println("s1  "+sta1);
        System.out.println("s2  "+sta2);

        sta1.close();
        sta2.close();
        System.out.println("s1·  "+sta1);
        System.out.println("s2·  "+sta2);

        conn1.close();
        conn2.close();
        System.out.println("c1  "+conn1);  //原来值
        System.out.println("c2  "+conn2);  //null
    }
}
